<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich">

<ui:composition template="/templates/main.xhtml">

  <ui:define name="content">

    <h:form id="list">

      <rich:dataTable value="#{mainSchoolList.mainSchools}" var="school" width="680" rows="25">

        <f:facet name="header">
          <h:outputText value="Main Schools" />
        </f:facet>

        <rich:column width="7">
          <f:facet name="header">
            <h:outputText value="Edit" />
          </f:facet>
          <a4j:commandLink reRender="schoolDetail" immediate="true">
            <a4j:actionparam name="id" value="#{school.id}" assignTo="#{schoolDetail.id}" />
            <a4j:actionparam name="action" value="#{base['crud.modify.short']}" assignTo="#{schoolDetail.action}" />
            <h:graphicImage id="edit" url="/images/edit.gif" border="0" />
          </a4j:commandLink>
        </rich:column>

        <rich:column width="7">
          <f:facet name="header">
            <h:outputText value="Del" />
          </f:facet>
          <a4j:commandLink reRender="schoolDetail" immediate="true">
            <a4j:actionparam name="id" value="#{school.id}" assignTo="#{schoolDetail.id}" />
            <a4j:actionparam name="action" value="#{base['crud.remove']}" assignTo="#{schoolDetail.action}" />
            <h:graphicImage id="del" url="/images/delete.gif" border="0" />
          </a4j:commandLink>
        </rich:column>

        <rich:column sortBy="#{school.name}">
          <f:facet name="header">
            <h:outputText value="Name" />
          </f:facet>
          <h:outputText value="#{school.name}" />
        </rich:column>

        <rich:column sortBy="#{school.description}">
          <f:facet name="header">
            <h:outputText value="Description" />
          </f:facet>
          <h:outputText value="#{school.description}" />
        </rich:column>

      </rich:dataTable>

      <rich:spacer width="1" height="20" />

      <a4j:commandLink reRender="schoolDetail" value="#{base['crud.add']}" immediate="true">
        <a4j:actionparam name="action" value="#{base['crud.add']}" assignTo="#{schoolDetail.action}" />
      </a4j:commandLink>

    </h:form>

    <rich:spacer width="1" height="20" />

    <a4j:outputPanel layout="none" ajaxRendered="true">
      <rich:panel id="schoolDetail" style="width:680;" rendered="#{schoolDetail.rendered}">
        <f:facet name="header">
          <h:outputText value="School Details"></h:outputText>
        </f:facet>
        <h:form>
          <rich:tabPanel switchType="client" height="200">
            <rich:tab label="Main">

              <style type="text/css">
.rich-message-marker img {
	padding-right: 7px;
}

.rich-message-label {
	color: red;
}
</style>
              <h:panelGrid columns="2" labelWidth="20%" fieldWidth="67%">

                <h:outputText value="#{base['school.name']}" />
                <h:panelGrid columns="2">
                  <h:inputText id="name" required="true" size="30" label="Name" value="#{schoolDetail.school.name}"
                    readonly="#{schoolDetail.readOnly}" disabled="#{schoolDetail.readOnly}" />
                  <rich:message for="name" />
                </h:panelGrid>

                <h:outputText value="#{base['school.description']}" />
                <h:inputText id="description" size="60" label="Description" value="#{schoolDetail.school.description}"
                  readonly="#{schoolDetail.readOnly}" disabled="#{schoolDetail.readOnly}" />

                <h:inputHidden id="selectedSchoolId" value="#{schoolDetail.id}" />
                <h:inputHidden id="selectedSchoolAction" value="#{schoolDetail.action}" />
              </h:panelGrid>
            </rich:tab>
            <rich:tab label="Address" disabled="#{schoolDetail.readOnly}">
            </rich:tab>
            <!-- 
            <rich:tab label="Administrators" disabled="#{schoolDetail.readOnly}">
              <rich:listShuttle sourceValue="#{userManager.schoolAdmins}" var="items" listHeight="300" listWidth="200"
                sourceCaptionLabel="Available Items" targetCaptionLabel="Currently Active Items">
                <rich:column>
                  <h:outputText value="#{items.name}"></h:outputText>
                </rich:column>
              </rich:listShuttle>
            </rich:tab>
 -->
          </rich:tabPanel>
          <rich:spacer width="1" height="10" />
          <a4j:commandLink value="#{schoolDetail.action}" immediate="#{schoolDetail.readOnly}"
            action="#{schoolDetail.persistSchool}">
            <a4j:actionparam name="action" value="#{schoolDetail.action}" assignTo="#{schoolDetail.action}" />
          </a4j:commandLink>
        </h:form>
      </rich:panel>
    </a4j:outputPanel>

  </ui:define>
</ui:composition>
</html>
